package com.fscp.feed.controller;

import com.fscp.commons.model.domain.ResultInfo;
import com.fscp.commons.model.pojo.Feed;
import com.fscp.commons.utils.ResultInfoUtil;
import com.fscp.feed.service.FeedService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
public class FeedController {

    @Resource
    private FeedService feedService;
    @Resource
    private HttpServletRequest request;

    /**
     * 添加 Feed
     *
     * @param feed
     * @param access_token
     * @return
     */
    @PostMapping
    public ResultInfo<String> create (@RequestBody Feed feed, String access_token) {
        feedService.create(feed, access_token);

        return ResultInfoUtil.buildSuccess(request.getServletPath(), "添加成功");
    }
}
